cmake_minimum_required(VERSION 2.8.3)
project(em80_driver)


set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wpedantic")

find_package(catkin REQUIRED COMPONENTS
  nodelet
  pluginlib
  roscpp
  std_msgs
  serial
  tf
  sensor_msgs
  nav_msgs
  em80_msgs
)

catkin_package(
  INCLUDE_DIRS include
  CATKIN_DEPENDS nodelet pluginlib roscpp std_msgs serial tf sensor_msgs nav_msgs
)

###########
## Build ##
###########

include_directories(
  include
  ${Boost_INCLUDE_DIRS}
  ${catkin_INCLUDE_DIRS}
  ${serial_INCLUDE_DIRS}
  
  
)

# node executable
add_executable(em80_driver_node src/packets/responses/adc.cpp
								src/packets/responses/battery.cpp
								src/packets/responses/core_sensors.cpp
								src/packets/responses/docking.cpp
								src/packets/responses/firmware.cpp
								src/packets/responses/gp_input.cpp
								src/packets/responses/status.cpp
								src/packet_base.cpp
                                #src/em80_driver_nodelet.cpp
								src/em80_driver_node.cpp
               					src/em80_driver.cpp
                                src/em80_interface.cpp
                                src/em80_payload_factory.cpp)
add_dependencies(em80_driver_node ${catkin_EXPORTED_TARGETS})
target_link_libraries(em80_driver_node
  ${catkin_LIBRARIES}
)

# nodelet library
#add_library(em80_driver_nodelet src/em80_driver_nodelet.cpp
#                                src/em80_driver.cpp
#                                src/em80_interface.cpp
#                                src/em80_packet.cpp
#                                src/em80_packet_factory.cpp)
#add_dependencies(em80_driver_nodelet ${catkin_EXPORTED_TARGETS})
#target_link_libraries(em80_driver_nodelet
#  ${catkin_LIBRARIES}
#)


#
# LIST EVERYTHING IN QT
#
file(GLOB_RECURSE ALL_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/*.hpp include/*.h)
add_custom_target(${PROJECT_NAME}_show_all_headers_in_qtc SOURCES ${ALL_HEADERS})


#############
## Install ##
#############

install(TARGETS em80_driver_node
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

#install(TARGETS em80_driver_nodelet
#  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
#)

install(DIRECTORY include/${PROJECT_NAME}/
        DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
install(FILES em80_driver_nodelet.xml
        DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
install(DIRECTORY launch/
        DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch)

#############
## Testing ##
#############

# TODO
